using System;
using System.Text;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using Crainiate.Data.Persistence.Providers;

namespace Crainiate.Data.Persistence
{
    public interface IPersistable
	{
        Concurrency Concurrency {get; set;}
	}

	public interface IQuery
	{
        Command Command {get; set;}
        Type Type {get;}
        Type ActivateType {get;}
		IResults Results {get; set;}
        IConditions Where {get; set;}
        IColumns GroupBy {get; set;}
        IConditions Having {get; set;}
        IColumns OrderBy {get; set;}
        IQueries SubQueries {get; set;}
        IQuery Parent {get; set;}
        bool Fill {get; set;}
        IColumns JoinFrom {get; set;}
        IColumns JoinTo {get; set;}
        JoinType JoinType {get;set;}

        void Execute();
	}

    public interface IQueries : IList<IQuery>
    {

    }

    public interface IResults: IList<IPersistable>
    {
        void Sort(ISort sort);
        Type ActivateType {get;}
        IRelationships Relationships { get; set;}
    }

    public interface IView
    {
        Type UnderlyingType();
    }

    public interface IColumn
    {
        PropertyInfo PropertyInfo { get;}
    }

    public interface IColumns: IList<IColumn>
    {

    }

	public interface ISort: IColumn
	{
		SortDirection Direction {get; set;}
	}

	public interface ICondition: IColumn
	{
		Comparison Comparison {get; set;}
		object Value {get; set;}
	}

    public interface IConditions: IList<ICondition>
    {
        Operator Operator {get; set;}
        IConditions SubConditions {get; set;}
    }

    public interface IAggregate: IColumn
    {
        AggregateType AggregateType { get; set;}
    }

    public interface IRelationship
    {
        IList<IPersistable> Parents { get;}
        IList<IPersistable> Children { get;}
        IPersistable Result { get;}
    }

    public interface IRelationships: System.Collections.Generic.IDictionary<IPersistable, IRelationship>
    {

    }

    //Attributes
    public interface IColumnAttribute
    {
    }

    public interface IPrimaryKeyColumnAttribute: IColumnAttribute
    {
    }


    public interface IIdentityColumnAttribute : IColumnAttribute
    {
        int Start { get;}
        int Increment { get;}
    }

    public interface ICompoundKeyColumnAttribute: IColumnAttribute
    {
        int Rank {get;}        
    }

    public interface IForeignKeyColumnAttribute: IColumnAttribute
    {
        Type References {get;}
    }
}
